home *** CD-ROM | disk | FTP | other *** search
/ Developer Helper 1: Phil & Dave's Excellent CD / Excellent CD HFS.raw / Moof / Goodies / HyperCard Goodies / HyperCard Dev. ToolKit / Serial & MacinTalk XCMDs / Flash.p < prev    next >
Text File  |  1987-06-15  |  1KB  |  68 lines

  1. {$R-}
  2.  
  3. (*
  4.     flash -- a sample HyperCard external command
  5.  
  6.     To compile and link this file using Macintosh Programmer's Workshop,
  7.  
  8.     pascal -w Flash.p
  9.     pascal -w XCmdUtil.p
  10.     asm -w XCmdUtil.a
  11.     link -m ENTRYPOINT -o HyperCommands -rt XCMD=0 -sn Main=Flash Flash.p.o ∂
  12.       XCmdUtil.p.o XCmdUtil.a.o "{MPW}"Libraries:interface.o
  13.     
  14. *)
  15.  
  16. {$S Flash }     { Segment name must be the same as the command name. }
  17.  
  18. UNIT DummyUnit;
  19.  
  20. INTERFACE
  21.  
  22. USES MemTypes, QuickDraw, HyperXCmd, XCmdUtil;
  23.  
  24. PROCEDURE EntryPoint(paramPtr: XCmdPtr);
  25.     
  26. IMPLEMENTATION
  27.  
  28. PROCEDURE Flash(paramPtr: XCmdPtr);                             FORWARD;
  29.  
  30.   PROCEDURE EntryPoint(paramPtr: XCmdPtr);
  31.   BEGIN
  32.     Flash(paramPtr);
  33.   END;
  34.  
  35.   PROCEDURE Flash(paramPtr: XCmdPtr);
  36.   VAR flashCount: LongInt;    
  37.       i: INTEGER;
  38.       port: GrafPtr;
  39.       str: Str255;
  40.       
  41.     PROCEDURE Fail(errMsg: Str255); { set theResult and quit }
  42.     BEGIN
  43.       paramPtr^.returnValue := PasToZero(errMsg);
  44.       EXIT(Flash);
  45.     END;
  46.  
  47.   BEGIN
  48.     IF paramPtr^.paramCount <> 1 THEN Fail('parameter count is not 1');
  49.     
  50.     ZeroToPas(paramPtr^.params[1]^,str);    { first param is flash count }
  51.     flashCount := StrToNum(str);
  52.     
  53.     IF ODD(flashCount) THEN Fail('can''t flash an odd number of times');
  54.     
  55.     GetPort(port);
  56.     FOR i := 1 TO flashCount DO 
  57.       BEGIN
  58.         InvertRect(port^.portRect);
  59.         InvertRect(port^.portRect);
  60.       END;
  61.   END;
  62.  
  63.  
  64. END.
  65.  
  66.  
  67.  
  68.